*Affinity or Effectiveness? Donors' Preferences for Bypass Aid
*Interaction Interactions Replication 
*Analysis file in dyadic format
*Last updatd: December 2023 
***

*Figure 1: NGO aid by sector (recipient-level CRS data by sector)
use "II_AllenFerryShammama_auxcrs_data.dta"
graph bar (mean) value, over(sector) scheme(s1mono)


*set up main analyses (dyad-level data)
use "II_AllenFerryShammama_data.dta"

global ldonor lGDP_growth1 lsocial_exp1 ltotal_aid1_gdp lleftexec1

global lrecipient lGDPpc2 lpopulation2_log lv2x_libdem2 lcivil_war2 lhr_latent2

*Figure 2: Bypass ratio by donor (below mean governance ONLY, exclude donors without no obs.) 
graph hbox nongov_total_log if nongov_total !=0 & lqog_all2<2.51 &ccode1 !=705 & ccode1 !=800 & ccode1 !=860 & ccode1 !=373 & ccode1 !=352 & ccode1 !=368 & ccode1 !=640, over(donor_name) scheme(s1mono)


**********************************************
*Main analyses 

*Table 1: Unconditional models 
regress nongov_total_log i.latopally_dyad c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log c.lexports_log_dyad c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log c.lipd_dyad c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad c.lqog_all c.lexports_log_dyad c.lipd_dyad $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

***

*Table 2: Conditional analyses 
regress nongov_total_log i.latopally_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Figure 3: Top panel
margins, at(lqog_all=(0(.1)6)) over(latopally_dyad)
marginsplot, scheme(s1mono) yline(0) recastci(rarea) 

regress nongov_total_log c.lexports_log_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Figure 3: Middle panel
margins, dydx(lqog_all) at(lexports_log_dyad=(2(0.5)26))
marginsplot, scheme(s1mono) yline(0) recastci(rarea) ///
	addplot(histogram lexports_log_dyad, yaxis(2) yscale(alt axis(2)) fcolor(%25) lc(black%50) legend(off)) 
	
regress nongov_total_log c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Figure 3: Bottom panel 
margins, dydx(lqog_all) at(lipd_dyad=(0(0.1)5))
marginsplot, scheme(s1mono) yline(0) recastci(rarea) 	///
	addplot(histogram lipd_dyad, yaxis(2) yscale(alt axis(2)) fcolor(%25) lc(black%50) legend(off)) 	
	
regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

**********************************************
*Appendix 

*Appendix A: Descriptives 	
graph bar (sum) valuemultilateral valuengo_cs valueppp valueprivate valuepublic valueteaching, scheme(s1color)

*(excludes donors without no obs.)
graph hbox nongov_total_zeros if nongov_total_zeros>0 & nongov_total_zeros!=. &ccode1 !=373 & ccode1!=352, over(donor_name) scheme(s1mono)

*Appendix B: Specification 
regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2 if failed_bottom15 !=1, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist nongov_total_log_lag year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist lNGO_law lccsi year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist i.year i.ccode1 i.ccode2, cluster(dyad_id)

*Appendix C: Alternative measures of bypass 
regress nongov_total i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress valuenongov_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2,cluster(dyad_id)

regress bypass_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress multi_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Appendix D: Alternative measures of governance 
regress nongov_total_log i.latopally_dyad##c.lqog_econ2 c.lexports_log_dyad##c.lqog_econ2 c.lipd_dyad##c.lqog_econ2 $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lsfi2_inv c.lexports_log_dyad##c.lsfi2_inv c.lipd_dyad##c.lsfi2_inv $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lfsi_total2_inv c.lexports_log_dyad##c.lfsi_total2_inv c.lipd_dyad##c.lfsi_total2_inv $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Appendix E: Alternative measures of strategic interests
regress nongov_total_log i.colony_dyad c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id) 

regress nongov_total_log i.colony_dyad##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log c.pc1 c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

regress nongov_total_log c.pc1##c.lqog_all $ldonor $lrecipient kmdist year i.ccode1 i.ccode2, cluster(dyad_id)

*Appendix F: Donor groups
*Minor 
regress nongov_total_log lqog_all i.latopally_dyad c.lexports_log_dyad  c.lipd_dyad $ldonor $lrecipient year kmdist i.ccode1 i.ccode2 if majorpower==0, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year kmdist i.ccode1 i.ccode2 if majorpower==0, cluster(dyad_id) 

*Major
regress nongov_total_log lqog_all i.latopally_dyad c.lexports_log_dyad  c.lipd_dyad $ldonor $lrecipient year kmdist i.ccode1 i.ccode2 if majorpower==1, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year kmdist i.ccode2 i.ccode1 if majorpower==1, cluster(dyad_id)

*Scandinavian 
regress nongov_total_log lqog_all i.latopally_dyad c.lexports_log_dyad  c.lipd_dyad $ldonor $lrecipient year kmdist i.ccode1 i.ccode2 if ccode1==380 | ccode1==385 | ccode1 == 390, cluster(dyad_id)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year kmdist i.ccode1 i.ccode2 if ccode1==380 | ccode1==385 | ccode1 == 390, cluster(dyad_id)


*Appendix G: Analyses by donor
*Major unconditional 
regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==2, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==200, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==220, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==260, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==740, cluster(ccode2)

*Major conditional 
regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==2, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==200, cluster(ccode2)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==220, cluster(ccode2)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==260, cluster(ccode2)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==740, cluster(ccode2)

*Scand. unconditional 
regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==390, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==380, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist if ccode1==385, cluster(ccode2)

*Scand conditional 
regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==390, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==380, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==385, cluster(ccode2) 

*Minor unconditional 
regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad  lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==20, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==205, cluster(ccode2)
 
regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==210, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist if ccode1==211, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==212, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==225, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==230, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==235, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist if ccode1==290, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==305, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==310, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist if ccode1==315, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==325, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==350, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist if ccode1==375, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==732, cluster(ccode2)

regress nongov_total_log lqog_all latopally_dyad lexports_log_dyad   lipd_dyad $ldonor $lrecipient year kmdist  if ccode1==920, cluster(ccode2)

*Minor conditional 
regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==20, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==205, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==210, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==211, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==212, cluster(ccode2)

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==225, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==230, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==235, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==290, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==305, cluster(ccode2)  

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==310, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year if ccode1==315, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==325, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==350, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==375, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year  if ccode1==732, cluster(ccode2) 

regress nongov_total_log i.latopally_dyad##c.lqog_all c.lexports_log_dyad##c.lqog_all c.lipd_dyad##c.lqog_all $ldonor $lrecipient year kmdist  if ccode1==920, cluster(ccode2) 
